<?php

namespace app\admin\model;

use app\model\Model;

class System extends Model
{
  public $privilege = 'base';
  public $cids;
  public $db;

  function __construct()
  {
    include 'check.php';
    new Check();

    $this->db = $GLOBALS['db'];
    $this->cids = checkAdminPriv(@$this->privilege); // 判断权限
    // $this->dataops = new \Dataops();
  }

  function index()
  {
    $this->tpl('system', [
      'db' => $this->db,
      'row' => file_get('json', 'system')
    ]);
  }

  function edit_action()
  {
    $data = get_post(['seoname', 'keywords', 'description']);

    $data['language'] = 'zh-cn';
    $data['template'] = 'default';

    if (file_it(json_encode($data, 320), 'json', 'system')) {
      // $sql = "UPDATE system SET " . arr_update($data) . " WHERE id = 1";

      // $this->dataops->ops($sql, '系统编辑', 1);
      admin_log('系统编辑');
      alert_href($GLOBALS['lang']['msg_success'], M('admin', 'system'));
      /*
      null_back($_POST['domain'], '请填写域名');
      null_back($_POST['name'], '请填写网络名称');

      $data['domain'] = str_safe($_POST['domain']);
      $data['name'] = str_safe($_POST['name']);
      $data['seoname'] = str_safe($_POST['seoname']);
      $data['keywords'] = str_safe($_POST['keywords']);
      $data['description'] = str_safe($_POST['description']);
      $data['copyright'] = str_isafe($_POST['copyright']);
      $data['user_audit'] = intval($_POST['user_audit']);
      $data['state'] = intval($_POST['state']);
      $data['gray'] = intval($_POST['gray']);
      */
    }
  }

  function __destruct()
  {
  }
}